package com.diankangwo.factory.service.impl;

import com.diankangwo.factory.dao.TdFactoryMapper;
import com.diankangwo.factory.entity.TdFactory;
import com.diankangwo.factory.service.TdFactoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/** 厂家接口实现类
 * Created by wuye on 2017/9/12.
 */
@Service("TdFactoryService")
public class TdFactoryServiceImpl implements TdFactoryService{

    @Autowired
    private TdFactoryMapper mapper;

    /**
     * 根据条件获取列表
     * @param map
     * @return
     */
    @Override
    public List<TdFactory> queryList(Map<String, Object> map) {
        return mapper.queryList(map);
    }

    /**
     * 根据条件获取总数
     * @param map
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return mapper.queryTotal(map);
    }

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Override
    public TdFactory queryById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    /**
     * 保存
     * @param tdFactory
     */
    @Override
    @Transactional
    public int save(TdFactory tdFactory) {
        return mapper.insert(tdFactory);
    }

    /**
     * 修改
     * @param tdFactory
     * @return
     */
    @Override
    @Transactional
    public int update(TdFactory tdFactory) {
        return mapper.updateByPrimaryKey(tdFactory);
    }

    /**
     * 删除
     * @param id
     */
    @Override
    @Transactional
    public void delete(int id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public TdFactory selectByClassId(Integer id) {
        return mapper.selectByClassId(id);
    }
}
